<template>
	<view>
		<u-notice-bar :text="text"></u-notice-bar>
		<view style="padding: 0 40rpx;margin: 40rpx 0;font-weight: 700;color: #e56564;">退款金额：￥{{obj.total}}</view>
		<view style="padding: 0 40rpx;margin: 40rpx 0;">
			<u--textarea v-model="value1" placeholder="请输入退款理由"></u--textarea>
		</view>
		<view style="padding: 0 40rpx;"><button style="color:#fff;background-color: #e56564;width: 100%;"
			 :disabled="disabled"	@click="refound">退款</button></view>
	</view>
</template>

<script>
	import {
		Add_Refund
	} from "../../../api/balance.js"
	export default {
		data() {
			return {
				text: '退款以实付金额为准，所享优惠不会退回。',
				value1: '',
				obj: {
					total:""
				},
				timer:'',
				disabled:false
			};
		},
		methods: {
			async refound() {
				if (this.value1 == '') {
					uni.showToast({
						title: '退款理由必填！',
						icon: "none"
					})
					return
				}
				this.disabled = true
				const res = await Add_Refund({
					openid: this.obj.openid,
					orderNo: this.obj.orderNo,
					total: this.obj.total,
					payState: this.obj.payState,
					remarks: this.value1,
				})
				this.disabled = false
				if (res == true) {
					uni.showToast({
						title: '申请成功！',
						icon: "success"
					})
					this.timer = setTimeout(() => {
						uni.navigateBack()
					}, 500)
				}
			}
		},
		// onLoad: function(option) {
		// 	console.log("退款信息",JSON.parse(option.i));
		// 	this.obj = JSON.parse(option.i)
		// },
		onShow() {
			this.obj = JSON.parse(uni.getStorageSync('refoundInfo')) ;
			console.log("退款信息",JSON.parse(this.obj));
		},
		onHide() {
			clearTimeout(this.timer)
		}
	}
</script>

<style lang="scss">

</style>
